package com.ruoyi.system.service.impl;

import com.ruoyi.system.entity.SysAnalysisUnit;
import com.ruoyi.system.mapper.SysAnalysisUnitMapper;
import com.ruoyi.system.service.SysAnalysisUnitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分析单元清单(SysAnalysisUnit)表服务实现类
 *
 * @author makejava
 * @since 2022-11-14 16:17:44*/


@Service("sysAnalysisUnitService")
public class SysAnalysisUnitServiceImpl implements SysAnalysisUnitService {
    @Resource
    private SysAnalysisUnitMapper sysAnalysisUnitDao;

/**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象*/


    @Override
    public SysAnalysisUnit queryById(Integer id) {
        return this.sysAnalysisUnitDao.queryById(id);
    }

/**
     * 分页查询
     *
     * @param sysAnalysisUnit 筛选条件
     * @return 查询结果*/


    @Override
    public List<SysAnalysisUnit> queryByPage(SysAnalysisUnit sysAnalysisUnit) {
        List<SysAnalysisUnit> sysAnalysisUnits = sysAnalysisUnitDao.queryAllByLimit(sysAnalysisUnit);
        return sysAnalysisUnits;
    }

/**
     * 新增数据
     *
     * @param sysAnalysisUnit 实例对象
     * @return 实例对象*/


    @Override
    public SysAnalysisUnit insert(SysAnalysisUnit sysAnalysisUnit) {
        this.sysAnalysisUnitDao.insert(sysAnalysisUnit);
        return sysAnalysisUnit;
    }

/**
     * 修改数据
     *
     * @param sysAnalysisUnit 实例对象
     * @return 实例对象*/


    @Override
    public SysAnalysisUnit update(SysAnalysisUnit sysAnalysisUnit) {
        this.sysAnalysisUnitDao.update(sysAnalysisUnit);
        return this.queryById(sysAnalysisUnit.getId());
    }

/**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功*/


    @Override
    public boolean deleteById(Integer id) {
        return this.sysAnalysisUnitDao.deleteById(id) > 0;
    }
}
